let { productsModel } = require('./models/productsModel.js');

//getProducts
module.exports.getProducts = async function() {
    return await productsModel.find().populate({
        path: 'typesId'
    });
};
//
// module.exports.searchProducts=async({})

//deleteProducts  by id
module.exports.deleteProducts = async(_id) => {
    // console.log(333,_id);
    // return await productsModel.updateOne(params, { delete: true }) //伪删除
    return await productsModel.deleteOne(_id)
}

//addProducts
module.exports.addProducts = async function(params) {
    let data = await productsModel.create(params);
    // console.log(333, data);
    return data;
};

//updateProducts